<?php
class scrollerImagesWidget extends CWidget
{
	public $title = 'Sản phẩm bán chạy';
	public $numberShow = 4;
	private $_url = '';
	public $data = array();
	public function init()
	{
		$dir = dirname(__FILE__).DIRECTORY_SEPARATOR.'assets';
		$this->_url = Yii::app()->getAssetManager()->publish($dir);
		$cs = Yii::app()->getClientScript();
		$cs->registerCssFile("{$this->_url}/css/scroller.css");
		$cs->registerCoreScript('jquery');
		$cs->registerScriptFile("{$this->_url}/js/scroller.js");
		$cs->registerScript(
				'scroller',
				"$(\"#amazon_scroller1\").amazon_scroller({
                    scroller_title_show: 'enable',
                    scroller_time_interval: '4000',
                    scroller_window_padding: '15',
                    scroller_images_width: '155',
                    scroller_images_height: '122',
                    scroller_title_size: '12',
                    scroller_title_color: '#333',
                    scroller_show_count: '".$this->numberShow."',
                    directory: '".$this->_url."/images'
                });",
				CClientScript::POS_READY
		);
		
		parent::init();
	}
	public function run()
	{
		$this->render('default', array(
				'title'=>$this->title,
				'data'=>$this->data
		));
	}
}